package com.kkb.dao;

import com.kkb.pojo.User;
import com.kkb.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserDao {
    QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

    public User signInHandler(String username, String password) throws SQLException {
        String sql = "select * from tb_users where username = ? and password = ?";
        Object[] params = {username, password};

        User user = this.queryRunner.query(sql, new BeanHandler<User>(User.class), params);
        return user;
    }
}
